<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Long Animation Frame Timing: blocking duration with events</title>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="resources/utils.js"></script>

<body>
<h1>Long Animation Frame: blocking duration with events</h1>
<div id="log"></div>
<output id="output"></output>
<script>
promise_test(async t => {
  const [entry, script] = await expect_long_frame_with_script(async () => {
    const button = document.createElement("button");
    button.innerText = "click";
    button.addEventListener("click", () => busy_wait());
    document.body.append(button);
    t.add_cleanup(() => button.remove());
    await test_driver.click(button);
  }, (script) => script.invoker === "BUTTON.onclick", t);
  assert_greater_than(entry.duration, 50);
  assert_greater_than_equal(entry.blockingDuration, 300);
}, "LoAF generated by events should generate correct blockingDuration");
</script>
</body>
